package com.jcf.springboot.controller.business;


import com.jcf.springboot.common.R;
import com.jcf.springboot.entity.business.Category;
import com.jcf.springboot.service.CategoryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author jjj
 * @since 2021-03-25
 */
@CrossOrigin
@RestController
@RequestMapping("/category")
public class CategoryController {

    @Autowired
    private CategoryService service;

    @GetMapping("getList")
    public R getList(){
        List<Category> list = service.list(null);
        if(list.size()>0){
            return R.ok().data(list).message("查询分类列表成功");
        }
        else {
            return R.error().message("查询分类列表失败");
        }
    }
}

